﻿using Gasgoo.ShareLibrary.Framework.Options;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Gasgoo.ShareLibrary.Framework.iQueueProvider
{
    public interface IQueueStorageProvider
    {
        string QueueId { get; set; }

        /// <summary>
        /// 出队
        /// </summary>
        /// <param name="maxCount">最多获取多少条</param>
        /// <returns></returns>
        Task<IEnumerable<MessageDataOptions>> DequeueAsync(int maxCount);

        /// <summary>
        /// 入队
        /// </summary>
        /// <param name="payload">消息内容</param>
        /// <returns></returns>
        Task EnqueueAsync(MessageDataOptions payload);

        /// <summary>
        /// 卸载
        /// </summary>
        /// <returns></returns>
        Task ShutdownAsync();

        /// <summary>
        /// 创建实例
        /// </summary>
        /// <param name="options">数据库配置</param>
        /// <param name="queueId">队列ID</param>
        /// <returns></returns>
        IQueueStorageProvider CreateInstance(IServiceProvider provider, string queueId);
    }
}
